﻿using System;
using System.Collections.Generic;
using System.Text;
namespace Notepad_X.Classes
{
    
    public static class Functions
    {
        public static bool ConnectionAvailable(string strServer)
        {
            try {
                System.Net.HttpWebRequest reqFP = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create(strServer);

                System.Net.HttpWebResponse rspFP = (System.Net.HttpWebResponse)reqFP.GetResponse();

                if (System.Net.HttpStatusCode.OK == rspFP.StatusCode)
                {
                    // HTTP = 200 - Internet connection available, server online
                    rspFP.Close();
                    return true;
                }
                else
                {
                    // Other status - Server or connection not available
                    rspFP.Close();
                    return false;
                }

            }catch (System.Net.WebException){
                // Exception - connection not available
                return false;
            }
        }
    }
}
